{
const char *checksum = value;
- if (!ostree_repo_traverse_commit (self, checksum, depth, data.reachable,
+ if (!ostree_repo_traverse_commit_union (self, checksum, depth, data.reachable,
cancellable, error))
goto out;
}
if (objtype != OSTREE_OBJECT_TYPE_COMMIT)
continue;
- if (!ostree_repo_traverse_commit (self, checksum, depth, data.reachable,
- cancellable, error))
+ if (!ostree_repo_traverse_commit_union (self, checksum, depth, data.reachable,
+ cancellable, error))
goto out;
}
}
ostree_repo_traverse_new_reachable (void)
{
return g_hash_table_new_full (ostree_hash_object_name, g_variant_equal,
- (GDestroyNotify)g_variant_unref, NULL);
+ NULL, (GDestroyNotify)g_variant_unref);
}
static gboolean
return ret;
}
-gboolean
-ostree_repo_traverse_dirtree (OstreeRepo *repo,
- const char *dirtree_checksum,
- GHashTable *inout_reachable,
- GCancellable *cancellable,
- GError **error)
-{
- return traverse_dirtree_internal (repo, dirtree_checksum, 0,
- inout_reachable, cancellable, error);
-}
-
/**
- * ostree_traverse_commit:
+ * ostree_repo_traverse_commit_union: (skip)
+ * @repo: Repo
+ * @commit_checksum: ASCII SHA256 checksum
+ * @maxdepth: Traverse this many parent commits, -1 for unlimited
+ * @inout_reachable: Set of reachable objects
+ * @cancellable: Cancellable
+ * @error: Error
*
- * Add to @inout_reachable all objects reachable from
- * @commit_checksum, traversing @maxdepth parent commits.
+ * Update the set @inout_reachable containing all objects reachable
+ * from @commit_checksum, traversing @maxdepth parent commits.
*/
gboolean
-ostree_repo_traverse_commit (OstreeRepo *repo,
- const char *commit_checksum,
- int maxdepth,
- GHashTable *inout_reachable,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_traverse_commit_union (OstreeRepo *repo,
+ const char *commit_checksum,
+ int maxdepth,
+ GHashTable *inout_reachable,
+ GCancellable *cancellable,
+ GError **error)
{
gboolean ret = FALSE;
- gs_free char*tmp_checksum = NULL;
+ gs_free char *tmp_checksum = NULL;
while (TRUE)
{
}
tmp_checksum = ostree_checksum_from_bytes_v (content_csum_bytes);
- if (!ostree_repo_traverse_dirtree (repo, tmp_checksum, inout_reachable, cancellable, error))
+ if (!traverse_dirtree_internal (repo, tmp_checksum, 0, inout_reachable, cancellable, error))
goto out;
if (maxdepth == -1 || maxdepth > 0)
out:
return ret;
}
+
+/**
+ * ostree_repo_traverse_commit:
+ * @repo: Repo
+ * @commit_checksum: ASCII SHA256 checksum
+ * @maxdepth: Traverse this many parent commits, -1 for unlimited
+ * @out_reachable: (out) (element-type GVariant GVariant): Set of reachable objects
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Create a new set @out_reachable containing all objects reachable
+ * from @commit_checksum, traversing @maxdepth parent commits.
+ */
+gboolean
+ostree_repo_traverse_commit (OstreeRepo *repo,
+ const char *commit_checksum,
+ int maxdepth,
+ GHashTable **out_reachable,
+ GCancellable *cancellable,
+ GError **error)
+{
+ gboolean ret;
+ gs_unref_hashtable GHashTable *ret_reachable =
+ ostree_repo_traverse_new_reachable ();
+
+ if (!ostree_repo_traverse_commit_union (repo, commit_checksum, maxdepth,
+ ret_reachable, cancellable, error))
+ goto out;
+
+ ret = TRUE;
+ gs_transfer_out_value (out_reachable, &ret_reachable);
+ out:
+ return ret;
+}
GHashTable *ostree_repo_traverse_new_reachable (void);
-gboolean ostree_repo_traverse_dirtree (OstreeRepo *repo,
- const char *commit_checksum,
- GHashTable *inout_reachable,
- GCancellable *cancellable,
- GError **error);
-
gboolean ostree_repo_traverse_commit (OstreeRepo *repo,
const char *commit_checksum,
int maxdepth,
- GHashTable *inout_reachable,
+ GHashTable **out_reachable,
GCancellable *cancellable,
GError **error);
+gboolean ostree_repo_traverse_commit_union (OstreeRepo *repo,
+ const char *commit_checksum,
+ int maxdepth,
+ GHashTable *inout_reachable,
+ GCancellable *cancellable,
+ GError **error);
+
/**
* OstreeRepoPruneFlags:
* @OSTREE_REPO_PRUNE_FLAGS_NONE: No special options for pruning
if (opt_stats)
{
- gs_unref_hashtable GHashTable *reachable_a = ostree_repo_traverse_new_reachable ();
- gs_unref_hashtable GHashTable *reachable_b = ostree_repo_traverse_new_reachable ();
+ gs_unref_hashtable GHashTable *reachable_a = NULL;
+ gs_unref_hashtable GHashTable *reachable_b = NULL;
gs_unref_hashtable GHashTable *reachable_intersection = NULL;
gs_free char *rev_a = NULL;
gs_free char *rev_b = NULL;
if (!ostree_repo_resolve_rev (repo, target, FALSE, &rev_b, error))
goto out;
- if (!ostree_repo_traverse_commit (repo, rev_a, -1, reachable_a, cancellable, error))
+ if (!ostree_repo_traverse_commit (repo, rev_a, -1, &reachable_a, cancellable, error))
goto out;
- if (!ostree_repo_traverse_commit (repo, rev_b, -1, reachable_b, cancellable, error))
+ if (!ostree_repo_traverse_commit (repo, rev_b, -1, &reachable_b, cancellable, error))
goto out;
a_size = g_hash_table_size (reachable_a);
g_assert (objtype == OSTREE_OBJECT_TYPE_COMMIT);
- if (!ostree_repo_traverse_commit (repo, checksum, 0, reachable_objects,
- cancellable, error))
+ if (!ostree_repo_traverse_commit_union (repo, checksum, 0, reachable_objects,
+ cancellable, error))
goto out;
}
{
const char *checksum = value;
- if (!ostree_repo_traverse_commit (data->src_repo, checksum, 0, source_objects,
- cancellable, error))
+ if (!ostree_repo_traverse_commit_union (data->src_repo, checksum, 0, source_objects,
+ cancellable, error))
goto out;
}
}
while (g_hash_table_iter_next (&hash_iter, &key, &value))
{
const char *checksum = key;
+ gs_unref_hashtable GHashTable *tmp_source_objects = NULL;
- if (!ostree_repo_traverse_commit (data->src_repo, checksum, 0, source_objects,
- cancellable, error))
+ if (!ostree_repo_traverse_commit_union (data->src_repo, checksum, 0, source_objects,
+ cancellable, error))
goto out;
}
}